package net.sf.odinms.tools;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.rmi.NotBoundException;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;

/**
 *
 * @author Bassoe
 *
 */
public class MonsterDropCreator {
    public static void main(String args[]) throws FileNotFoundException, IOException, NotBoundException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, MalformedObjectNameException {
	    //start the dump
        /*MapleData data = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("net.sf.odinms.wzpath") + "/String.wz")).getData("MonsterBook.img");
        boolean first;
        Properties dbProp = new Properties();
        FileReader fr = new FileReader("db.properties");
        dbProp.load(fr);
        fr.close();
        DatabaseConnection.setProps(dbProp);
        Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps;
        for (MapleData dataz : data.getChildren()) {
            int monsterId = Integer.parseInt(dataz.getName());
            String Query = "INSERT INTO monsterdrops VALUES ";
            first = true;
            for (MapleData drop : dataz.getChildByPath("reward")) {
                int itemid = MapleDataTool.getInt(drop);
                if (first) {
                    Query += "(DEFAULT, " + monsterId + ", " + itemid + ", " + getChance(itemid) + ")";
                    first = false;
                } else
                    Query += ", (DEFAULT, " + monsterId + ", " + itemid + ", " + getChance(itemid) + ")";
            }
            try {
                ps = con.prepareStatement(Query);
                ps.executeUpdate();
                ps.close();
            } catch (SQLException e) {}
        }*/
    }

    public static int getChance(int id) {
        switch (id / 10000) {
            case 413:
                return 1000;
            case 204:
                return 12000;
            case 400:
                switch (id / 1000) {
                    case 4000:
                    case 4001:
                        return 5;
                    case 4003:
                        return 200;
                    case 4004:
                    case 4006:
                        return 1500;
                    case 4005:
                        return 100;
                }
            case 401:
            case 402:
            case 416:
                return 600;
            case 403:
                return 300;
        }
        switch (id / 1000000) {
            case 1:
                return 2400;
            case 2:
                switch (id) {
                    case 2000000:
                    case 2000002:
                    case 2000003:
                    case 2000004:
                    case 2000005:
                    case 2000006:
                    case 2001001:
                    case 2002000:
                    case 2002001:
                    case 2002003:
                    case 2002004:
                    case 2002006:
                    case 2002011:
                    case 2010009:
                    case 2012001:
                    case 2012002:
                    case 2022001:
                    case 2020013:
                    case 2020014:
                    case 2020015:
                    case 2022142:
                    case 2022186:
                        return 100;
                    case 2060000:
                    case 2061000:
                    case 2060001:
                    case 2061001:
                        return 200;
                    case 2070000:
                    case 2070001:
                    case 2070002:
                    case 2070003:
                    case 2070004:
                    case 2070005:
                    case 2070006:
                    case 2070007:
                    case 2070008:
                    case 2070009:
                    case 2070010:
                        return 10000;
                    default:
                        return 400;
                }
        }
        return 0;
    }
}